'''
Author: your name
Date: 2021-08-14 00:52:46
LastEditTime: 2021-08-15 01:44:55
LastEditors: Please set LastEditors
Description: In User Settings Edit
FilePath: \python\neteasenews.py
'''
import asyncio
from asyncio.tasks import sleep
from requests_html import HTMLSession
import html2text
from elasticsearch_dsl import (
    
    Document,
    SearchAsYouType,
    analyzer,
    connections,
    token_filter,
    Search
)


x = { "2": 1,"3":4}
print(type(x))
print("u"  in x)

### program start
session = HTMLSession()
url = "https://www.163.com"
payload = {}
headers = {
}
script='''
()=>{
Object.defineProperties(navigator,{
        webdriver:{
        get: () => undefined
        }
    })}'''
response = session.request("GET", url)
response.encoding = 'utf-8'
tbl = {}
alls = []
response.html.render(script=script)

try:
    response.html.render(keep_page=True,timeout = 0,sleep = 0)
    async def main():
        await response.html.page.waitFor(100)
        objselect = response.html.find("a")
        for i in range(len(objselect)):
            if('data-c' in objselect[i].attrs ):
                if(objselect[i].attrs['data-c'] == "新闻"):
                    print(objselect[i].attrs['href'])

    asyncio.get_event_loop().run_until_complete(main())
    print("finish")
except Exception as e:
    print(e)        